// Problem 2: Even Fibonacci numbers
// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
// Find the sum of the even-valued terms, below 4,000,000.

package main

import (
	"fmt"
)

func p002() int {
	a, b := 1, 1
	fib := func() {
		// a, b = b, a+b
		ab := a + b
		a, b = ab+b, 2*ab+b
	}
	sum := 0
	for a+b < 4000000 {
		sum += a + b
		fib()
	}
	fmt.Println("Problem 002:", sum)
	return sum
}
